<template>
  <div class="clue-trans-config-container">
    <!-- 标签页头部 -->
    <div class="tab-header">
      <div class="header-icon">
        <Icon icon="ep:connection" />
      </div>
      <div class="header-content">
        <h4 class="header-title">线索转换配置</h4>
        <p class="header-subtitle">配置不同类型的线索转换规则</p>
      </div>
    </div>

    <!-- 标签页导航 -->
    <div class="tab-navigation">
      <el-radio-group v-model="activeName" size="large" class="enhanced-radio-group">
        <el-radio-button value="1" label="1" class="radio-button-item">
          <div class="button-content">
            <Icon icon="ep:phone" class="button-icon" />
            <span class="button-text">系统群呼线索</span>
          </div>
        </el-radio-button>
        <el-radio-button value="2" label="2" v-if="sipMode == 'cm'" class="radio-button-item">
          <div class="button-content">
            <Icon icon="ep:cpu" class="button-icon" />
            <span class="button-text">机器人群呼线索</span>
          </div>
        </el-radio-button>
        <el-radio-button value="3" label="3" class="radio-button-item">
          <div class="button-content">
            <Icon icon="ep:promotion" class="button-icon" />
            <span class="button-text">广告线索</span>
          </div>
        </el-radio-button>
      </el-radio-group>
    </div>

    <!-- 内容区域 -->
    <div class="tab-content">
      <BatchCallClue v-if="activeName == '1'" :module-id="props.moduleId" />
      <AdClue v-if="activeName == '3'" :module-id="props.moduleId" />
      <RobotClue v-if="activeName == '2' && sipMode == 'cm'" :module-id="props.moduleId" />
    </div>
  </div>
</template>

<script setup lang="ts">
import AdClue from './adClue/index.vue'
import RobotClue from './robotClue/index.vue'
import BatchCallClue from './batchCallClue/index.vue'
const activeName = ref('1')
import { useUserStore } from '@/store/modules/user'

const props = defineProps({
  moduleId: {
    type: Number
  }
})
const sipMode = ref('')
onMounted(() => {
  sipMode.value = useUserStore().getSipMode
})
</script>

<style scoped lang="scss">
// 主题色变量
$primary-color: #0052cc;
$primary-light: rgba(0, 82, 204, 0.1);
$primary-border: rgba(0, 82, 204, 0.3);
$success-color: #67c23a;
$warning-color: #e6a23c;
$danger-color: #f56c6c;
$info-color: #909399;
$text-primary: #303133;
$text-regular: #606266;
$text-secondary: #909399;
$text-placeholder: #c0c4cc;
$border-color: #dcdfe6;
$border-light: #e4e7ed;
$bg-color: #f5f7fa;
$shadow-light: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
$shadow-base:
  0 2px 4px rgba(0, 0, 0, 0.12),
  0 0 6px rgba(0, 0, 0, 0.04);
$border-radius: 12px;
$border-radius-small: 8px;

.clue-trans-config-container {
  padding: 0;
  background: $bg-color;

  @media (max-width: 768px) {
    padding: 0;
  }
}

/* 标签页头部 */
.tab-header {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  background: linear-gradient(135deg, $primary-color 0%, #1d4ed8 100%);
  color: white;
  margin-bottom: 16px;

  @media (max-width: 768px) {
    padding: 16px 20px;
    flex-direction: column;
    gap: 8px;
    text-align: center;
    margin-bottom: 12px;
  }

  .header-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: $border-radius-small;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;

    @media (max-width: 768px) {
      width: 36px;
      height: 36px;
      font-size: 16px;
    }
  }

  .header-content {
    flex: 1;
    margin-left: 12px;

    @media (max-width: 768px) {
      margin-left: 0;
    }
  }

  .header-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px 0;

    @media (max-width: 768px) {
      font-size: 16px;
    }
  }

  .header-subtitle {
    font-size: 13px;
    opacity: 0.9;
    margin: 0;

    @media (max-width: 768px) {
      font-size: 12px;
    }
  }
}

/* 标签页导航 */
.tab-navigation {
  padding: 24px;
  background: white;
  border-radius: $border-radius $border-radius 0 0;
  box-shadow: $shadow-light;
  border: 1px solid $border-light;
  border-bottom: none;

  @media (max-width: 768px) {
    padding: 0 16px 16px;
  }
}

.enhanced-radio-group {
  display: flex;
  gap: 12px;
  width: 100%;

  @media (max-width: 768px) {
    flex-direction: column;
    gap: 8px;
  }

  :deep(.el-radio-button) {
    flex: 1;
    border-radius: $border-radius-small;
    overflow: hidden;
    box-shadow: $shadow-base;
    transition: all 0.3s ease;

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 16px rgba(0, 82, 204, 0.2);
    }

    @media (max-width: 768px) {
      flex: none;
    }
  }

  :deep(.el-radio-button__inner) {
    border: 2px solid $border-color;
    border-radius: $border-radius-small;
    background: white;
    color: $text-regular;
    font-weight: 500;
    padding: 12px 16px;
    width: 100%;
    height: auto;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;

    &:hover {
      border-color: $primary-color;
      color: $primary-color;
      background: $primary-light;
    }

    @media (max-width: 768px) {
      padding: 14px 16px;
      font-size: 14px;
    }
  }

  :deep(.el-radio-button__original-radio:checked + .el-radio-button__inner) {
    background: $primary-color;
    border-color: $primary-color;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 82, 204, 0.3);

    .button-icon {
      color: white;
    }
  }

  :deep(.el-radio-button:first-child .el-radio-button__inner) {
    border-left: 2px solid $border-color;
  }

  :deep(.el-radio-button:last-child .el-radio-button__inner) {
    border-right: 2px solid $border-color;
  }
}

.radio-button-item {
  .button-content {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;

    @media (max-width: 768px) {
      gap: 6px;
    }
  }

  .button-icon {
    font-size: 16px;
    color: $primary-color;
    transition: all 0.3s ease;

    @media (max-width: 768px) {
      font-size: 14px;
    }
  }

  .button-text {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;

    @media (max-width: 768px) {
      font-size: 13px;
    }
  }
}

/* 内容区域 */
.tab-content {
  background: white;
  border-radius: 0 0 $border-radius $border-radius;
  box-shadow: $shadow-light;
  border: 1px solid $border-light;
  border-top: none;
  overflow: hidden;
  padding: 12px;

  @media (max-width: 768px) {
    min-height: 300px;
  }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .clue-trans-config-container {
    background: #1f2937;
  }

  .tab-navigation,
  .tab-content {
    background: #374151;
    border-color: #4b5563;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  .header-title {
    color: #f9fafb;
  }

  .header-subtitle {
    color: rgba(249, 250, 251, 0.9);
  }

  .enhanced-radio-group {
    :deep(.el-radio-button__inner) {
      background: #4b5563;
      border-color: #6b7280;
      color: #f9fafb;

      &:hover {
        border-color: #60a5fa;
        color: #60a5fa;
        background: rgba(96, 165, 250, 0.1);
      }
    }

    :deep(.el-radio-button__original-radio:checked + .el-radio-button__inner) {
      background: #60a5fa;
      border-color: #60a5fa;
      color: white;
      box-shadow: 0 2px 8px rgba(96, 165, 250, 0.3);

      .button-icon {
        color: white;
      }
    }

    :deep(.el-radio-button:first-child .el-radio-button__inner) {
      border-left-color: #6b7280;
    }

    :deep(.el-radio-button:last-child .el-radio-button__inner) {
      border-right-color: #6b7280;
    }
  }

  .radio-button-item .button-icon {
    color: #60a5fa;
  }
}

/* 响应式优化 */
@media (max-width: 480px) {
  .tab-header {
    padding: 12px 16px;
  }

  .tab-navigation {
    padding: 0 12px 12px;
  }

  .enhanced-radio-group {
    gap: 6px;

    :deep(.el-radio-button__inner) {
      padding: 12px 14px;
      font-size: 13px;
    }
  }

  .radio-button-item {
    .button-content {
      gap: 4px;
    }

    .button-icon {
      font-size: 13px;
    }

    .button-text {
      font-size: 12px;
    }
  }

  .tab-content {
    min-height: 250px;
  }
}

/* 动画效果 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tab-content {
  animation: fadeInUp 0.3s ease-out;
}

/* 滚动条美化 */
.tab-content {
  &::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  &::-webkit-scrollbar-track {
    background: $bg-color;
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb {
    background: $border-color;
    border-radius: 3px;
    transition: all 0.3s ease;

    &:hover {
      background: $primary-color;
    }
  }
}
</style>
